<template>
  <div>
    <city-header></city-header>
    <city-search :cities="cities"></city-search>
    <city-list
    :letter="letter"
    :cities="cities"
    :hotCities="hotCities">
    </city-list>
    <city-alphabet :cities="cities" @change="handleLetterChange"></city-alphabet>
  </div>
</template>

<script>
import axios from 'axios'
import CityHeader from './components/header'
import CitySearch from './components/search'
import CityList from './components/list'
import CityAlphabet from './components/alphabet'
export default {
  name: 'city',
  data () {
    return {
      cities: {},
      hotCities: [],
      letter: ''
    }
  },
  components: {CityHeader, CitySearch, CityList, CityAlphabet},
  mounted () {
    this.getCityInfo()
  },
  methods: {
    getCityInfo () {
      axios.get('https://www.easy-mock.com/mock/5b335032b3c5711bec1ff3b9/travel/city').then(res => {
        // debugger
        if (res.data.ret) {
          console.log(res)
          this.cities = res.data.data.cities
          this.hotCities = res.data.data.hotCities
        }
      })
    },
    handleLetterChange (letter) {
      this.letter = letter
    }
  }
}
</script>

<style lang="stylus" scoped>

</style>
